package com.my.xadmin.security.entity;

import com.my.framework.base.entity.IdLongEntity;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.validator.constraints.Range;

import javax.persistence.*;
import javax.validation.constraints.NotNull;

@Entity
@Table(name="security_organization_role")
public class OrganizationRole extends IdLongEntity {

	/** 值越小，优先级越高. */
	@NotNull
	@Range(min=1, max=99)
	@Column(length=2, nullable=false)
	private Integer priority = 99;
	
	/** 角色外键. */
	@ManyToOne(fetch= FetchType.LAZY)
	@JoinColumn(name="roleId")
	private Role role;
	
	/** 机构外键. */
	@ManyToOne(fetch= FetchType.LAZY)
	@JoinColumn(name="organizationId")
	private Organization organization;

	/**
	 * Gets the 值越小，优先级越高.
	 * 
	 * @return the 值越小，优先级越高
	 */
	public Integer getPriority() {
		return priority;
	}

	/**
	 * Sets the 值越小，优先级越高.
	 * 
	 * @param priority
	 *            the new 值越小，优先级越高
	 */
	public void setPriority(Integer priority) {
		this.priority = priority;
	}

	/**
	 * Gets the 角色外键.
	 * 
	 * @return the 角色外键
	 */
	public Role getRole() {
		return role;
	}

	/**
	 * Sets the 角色外键.
	 * 
	 * @param role
	 *            the new 角色外键
	 */
	public void setRole(Role role) {
		this.role = role;
	}

	/**
	 * Gets the 机构外键.
	 * 
	 * @return the 机构外键
	 */
	public Organization getOrganization() {
		return organization;
	}

	/**
	 * Sets the 机构外键.
	 * 
	 * @param organization
	 *            the new 机构外键
	 */
	public void setOrganization(Organization organization) {
		this.organization = organization;
	}
	
}
